﻿using SX_MesProject.SchedulingTasks;
using SX_MesProject.Warehouse;
using SX_MesProject.YS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Controls.Ribbon;
using System.Windows.Forms;

namespace SX_MesProject
{
    public partial class Form1 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public Form1()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<UserList>(true);
        }

        private void navBarItem3_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<ProductionPlan>(true);
        }
        public void ShowWindows<F>(bool alone) where F : Form, new()
        {
            try
            {
                if (alone)
                {
                    foreach (Form form in this.MdiChildren)
                    {
                        if (form.GetType().Equals(typeof(F)))
                        {
                            form.Activate();
                            return;
                        }
                    }
                }
                F f = new F();
                f.MdiParent = this;
                f.Show();
            }
            catch
            {
                // 异常处理
            }
        }

        private void barEditItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }

        private void navBarItem5_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<InventoryLocationManage>(true);

        }

        private void navBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<WarehouseManagement>(true);
        }

        private void navBarItem8_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<Process_Management>(true);
        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<SchedulingTasksList>(true);
        }

        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            ShowWindows<MesWorkorderJobInfo>(true); 
        }
    }
}
